//    Copyright (C) Kherty.  All rights reserved.
using System;
using OpenLS.Core.Serialization;

namespace OpenLS.Spreadsheet.Data
{
    public class OlapConnection: DataConnection
    {
        private bool _local;

        public bool Local
        {
            get { return _local; }
            set { _local = value; }
        }
        private string _localConnection;

        public string LocalConnection
        {
            get { return _localConnection; }
            set { _localConnection = value; }
        }
        private bool _localRefresh = true;

        public bool LocalRefresh
        {
            get { return _localRefresh; }
            set { _localRefresh = value; }
        }
        private bool _sendLocale;

        public bool SendLocale
        {
            get { return _sendLocale; }
            set { _sendLocale = value; }
        }
        private int _rowDrillCount;

        public int RowDrillCount
        {
            get { return _rowDrillCount; }
            set { _rowDrillCount = value; }
        }
        private bool _serverFill = true;

        public bool ServerFill
        {
            get { return _serverFill; }
            set { _serverFill = value; }
        }
        private bool _serverNumberFormat = true;

        public bool ServerNumberFormat
        {
            get { return _serverNumberFormat; }
            set { _serverNumberFormat = value; }
        }
        private bool _serverFont = true;

        public bool ServerFont
        {
            get { return _serverFont; }
            set { _serverFont = value; }
        }
        private bool _serverFontColor=  true;

        public bool ServerFontColor
        {
            get { return _serverFontColor; }
            set { _serverFontColor = value; }
        }


        internal override void  ReadProperties(ReadContext context)
{
 	        using (ReadContext c = context.Read("olapPr"))
            {
                Local = c.GetOptionalBoolean("local", false);
                LocalConnection = c.GetOptionalString("localConnection");
                LocalRefresh = c.GetOptionalBoolean("localRefresh", true);
                SendLocale = c.GetOptionalBoolean("sendLocale", false);
                RowDrillCount = c.GetOptionalUIntegerAsInteger("rowDrillCount", 0);
                ServerFill = c.GetOptionalBoolean("serverFill", true);
                ServerNumberFormat = c.GetOptionalBoolean("serverNumberFormat", true);
                ServerFont = c.GetOptionalBoolean("serverFont", true);
                ServerFontColor = c.GetOptionalBoolean("serverFontColor", true);
            }
        }

        internal override void  WriteProperties(WriteContext context)
        {
 	        using (WriteContext c = context.Write("olapPr"))
            {
                c.SetOptionalBoolean("local", Local, false);
                c.SetOptionalString("localConnection", LocalConnection);
                c.SetOptionalBoolean("localRefresh", LocalRefresh, true);
                c.SetOptionalBoolean("sendLocale", SendLocale, false);
                c.SetOptionalUIntegerAsInteger("rowDrillCount", RowDrillCount, 0);
                c.SetOptionalBoolean("serverFill", ServerFill, true);
                c.SetOptionalBoolean("serverNumberFormat", ServerNumberFormat, true);
                c.SetOptionalBoolean("serverFont", ServerFont, true);
                c.SetOptionalBoolean("serverFontColor", ServerFontColor, true);
            }
        }


        internal override void SetTypeIfNecessary()
        {
            if (Type == DataConnectionType.Unknown)
                throw new NotImplementedException();
        }

        internal override void Initialize()
        {
            
        }
    }
}
